#include<iostream>
#include<unistd.h>
#include<unordered_map>
#include<memory>
#include "Thread.hpp"

const int num = 10;

using thread_ptr_t = shared_ptr<ThreadModule::Thread>;

int main()
{
    std::unordered_map<string, thread_ptr_t> threads;

    for(int i = 0; i < num; i++)
    {
        thread_ptr_t t = make_shared<ThreadModule::Thread>([](){
            while(1)
            {
                std::cout<<"hello thread"<<std::endl;
                sleep(1);
            }
        });
        threads[t->Name()] = t;
    }

    for(auto& t : threads)
    {
        t.second->Start();
    }
    for(auto& t : threads)
    {
        t.second->Join();
    }
    // ThreadModule::Thread t([](){
    //     while(1)
    //     {
    //         cout<<"hello thread"<<endl;
    //     }
    // });

    // t.Start();
    // cout<<t.Name()<<"is running"<<endl;
    // sleep(1);
    // t.Stop();
    // cout<<"stop thread:"<<t.Name()<<endl;
    // sleep(1);
    // t.Join();
    // cout<<"join thread:"<<t.Name()<<endl;
    // return 0;
}